import Taro, { Component } from '@tarojs/taro'
import { View, Text } from '@tarojs/components'
import './collectlist.css'
import { AtList, AtListItem } from "taro-ui"
import reactMixin from 'react-mixin';
import myJs from './collectlistJs.js'
import app from '../../../../main.js'


export default class CollectList extends Component {

  config = {
    navigationBarTitleText: '收藏列表'
  }
  constructor () { 
        super(...arguments); 
        this.state = this.getData(); 
    }
  init () { this.allFavor()}
  
  navTo (type,id) {
    console.log(123)
    if(type == '动态'){
       app.navigateTo('../../../dynamic/pages/dongtaixiangqing/dongtaixiangqing?chat_id='+id)
    }else if(type == '话题'){
       app.navigateTo('../../../dynamic/pages/huati/huati?id='+id)
    }
  }

  render () {
    
    return (
      <View className='collect-list'>
        <AtList>
            {this.state.favors.items.map((item) =>
                <AtListItem arrow='right' title={item.title} note={item.created_at} extraText={item.content_type} onClick={this.navTo.bind(this,item.content_type,item.relate_id)}/>
            )}
        </AtList>
        
      </View>
    )
  }
}
reactMixin.onClass(CollectList,myJs);
